namespace Entity.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Banco",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CodBanco = c.Int(nullable: false),
                        Descricao = c.String(maxLength: 80),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Deposito",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        BancoId = c.Int(nullable: false),
                        Valor = c.Decimal(nullable: false, precision: 18, scale: 2),
                        DataDeposito = c.DateTime(nullable: false),
                        UsuarioID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Banco", t => t.BancoId, cascadeDelete: true)
                .ForeignKey("dbo.Usuario", t => t.UsuarioID, cascadeDelete: true)
                .Index(t => t.BancoId)
                .Index(t => t.UsuarioID);
            
            CreateTable(
                "dbo.Usuario",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        User = c.String(maxLength: 100),
                        Password = c.String(maxLength: 100),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Despesa",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CategoriaDespesaID = c.Int(nullable: false),
                        Valor = c.Decimal(nullable: false, precision: 18, scale: 2),
                        DataPagamento = c.DateTime(nullable: false),
                        UsuarioID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CategoriaDespesa", t => t.CategoriaDespesaID, cascadeDelete: true)
                .ForeignKey("dbo.Usuario", t => t.UsuarioID, cascadeDelete: true)
                .Index(t => t.CategoriaDespesaID)
                .Index(t => t.UsuarioID);
            
            CreateTable(
                "dbo.CategoriaDespesa",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Descricao = c.String(maxLength: 80),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.Recebimento",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        CategoriaRecebimentoId = c.Int(nullable: false),
                        ValorRecebido = c.Decimal(nullable: false, precision: 18, scale: 2),
                        DataRecebimento = c.DateTime(nullable: false),
                        UsuarioID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.CategoriaRecebimento", t => t.CategoriaRecebimentoId, cascadeDelete: true)
                .ForeignKey("dbo.Usuario", t => t.UsuarioID, cascadeDelete: true)
                .Index(t => t.CategoriaRecebimentoId)
                .Index(t => t.UsuarioID);
            
            CreateTable(
                "dbo.CategoriaRecebimento",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Descricao = c.String(maxLength: 80),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Deposito", "UsuarioID", "dbo.Usuario");
            DropForeignKey("dbo.Recebimento", "UsuarioID", "dbo.Usuario");
            DropForeignKey("dbo.Recebimento", "CategoriaRecebimentoId", "dbo.CategoriaRecebimento");
            DropForeignKey("dbo.Despesa", "UsuarioID", "dbo.Usuario");
            DropForeignKey("dbo.Despesa", "CategoriaDespesaID", "dbo.CategoriaDespesa");
            DropForeignKey("dbo.Deposito", "BancoId", "dbo.Banco");
            DropIndex("dbo.Deposito", new[] { "UsuarioID" });
            DropIndex("dbo.Recebimento", new[] { "UsuarioID" });
            DropIndex("dbo.Recebimento", new[] { "CategoriaRecebimentoId" });
            DropIndex("dbo.Despesa", new[] { "UsuarioID" });
            DropIndex("dbo.Despesa", new[] { "CategoriaDespesaID" });
            DropIndex("dbo.Deposito", new[] { "BancoId" });
            DropTable("dbo.CategoriaRecebimento");
            DropTable("dbo.Recebimento");
            DropTable("dbo.CategoriaDespesa");
            DropTable("dbo.Despesa");
            DropTable("dbo.Usuario");
            DropTable("dbo.Deposito");
            DropTable("dbo.Banco");
        }
    }
}
